/** @jsxImportSource @emotion/react */
import * as React from "react";
import { OriginalViewProps, } from "../../common/base";
import {EntranceSetup} from "./orcBase";
import { createItem, } from "../../common/eHelper";
import { useRecordListSubr} from "../../hook/useRecordListSub";
import {PropertySolidify} from "../../industrial/EditorFeature";
import {SingleLineDiagram} from "../../industrial/editorLineDg";
import {IPipingUnitEntity} from "../../../comp/ChoosePipingUnits";
import {ConclusionPlas, config设备概况,} from "./Conclusion";
import {ProjectListRq} from "../../vessel/editProj";
import {DeviceSurvey} from "../../elevator/editor";
import {ConclusionAppendix} from "../plastics/ConclusionAppendix";

export const Projects默认=[
    {name:'公用管道全面检验结论报告',do:true,ha:'Conclusion'},
    //可重复的分项： 简易模式的。【特别形态的】结论附页： 不是单独打印一页的。 na:不在目录显示的；
    {name:'公用管道全面检验结论报告附页', ha:'ConclusionAppendix',na:true},
    //未发现已经有的模板？
    {name:'资料审查报告',ha:''},
    {name:'管道风险预评估报告',ha:''},
    {name:'宏观检查报告',ha:''},
    {name:'敷设环境调查报告',ha:''},
    {name:'防腐（保温）层状况不开挖检测报告',ha:''},
    {name:'阴极保护有效性检测报告',ha:''},
    {name:'腐蚀防护系统评价报告',ha:''},
    {name:'开挖直接检验报告',ha:''},
    {name:'穿、跨越段管道检查报告',ha:''},
    {name:'管道风险再评估报告',ha:''},
    // {name:'管道特性表',do:true,ha:'Characteristics',zs:true},
    {name:'管道特性表', do:true,ha:'Characteristics'},
    //【改】原报告页头加了：工程名称：[]？ 【多此一举】 关联到特性表上面去。 或者直接从挂接的特性 单元表的第一个单元同步过来字段。
    //这个页面不是录入： 单元台账上面每个单元都已经做呢相关录入。 图片上也会自带定位信息的。
    {name:'管道单线图', ha:'PipeLineDiagram',},
    {name:'附件三管道风险再评估附件',ha:''},
    {name:'其他', ha:''},
];

const recordPrintList =[
    createItem('Entrance', <EntranceSetup/>),
    createItem('ProjectList', <ProjectListRq config={Projects默认}  label={'目录页'}/>),
              // createItem('Survey', <ConclusionSurvey  label={'公用管道全面检验结论报告-设备概况'}/>),
    createItem('Survey', <DeviceSurvey config={config设备概况} label={'公用管道全面检验结论报告-设备概况'}/>),
    createItem('Conclusion', <ConclusionPlas label={'公用管道全面检验结论报告-下结论'}/>),

    createItem('ConclusionAppendix', <ConclusionAppendix table={'附页表'} label='全面检验结论报告附页'/>),

    createItem('Solidify', <PropertySolidify label={'管道特性表-管理器'} filterCB={modelToRepData}/>),
    createItem('LineDiagram', <SingleLineDiagram />),
    createItem('_Controller',  <></>),
];


//针对这个模板CharacteristRow()需要显示字段： 从Relay模型获取报告才需要的字段：svp pa只保存有用到的字段：但是PropertySolidify必须提取全面useLazyLoadQuery<typeof EditorFeatureQuery>。
function modelToRepData(pipe:IPipingUnitEntity){
  const {id,crDate,name,code,leng,level,start,stop,lay,thik,rno,dia,svp,pa,proj,insd,used,desu,insu}=pipe as any;
  const {材料,设压,设温,直径,腐蚀}=svp;
  const {工介,工压,工温,试压,防腐材,沥青级,防腐厚}=pa;
  //节约存储; 后端报告中：不需要存储usue{id,name}；
  return {
    id,crDate, name,code,leng,level,start,stop,lay,thik,rno,dia,proj,insd,used,desu,insu,
    svp:{材料,设压,设温,直径,腐蚀},
    pa:{工介,工压,工温,试压,防腐材,沥青级,防腐厚}
  };
}

export const OriginalView=
  React.forwardRef((
    { action: modAction,  verId, repId='', rep}
    :OriginalViewProps, ref
  ) => {
    const {list}=useRecordListSubr(ref,rep,recordPrintList,modAction,verId);
    return <React.Fragment>
      {list}
    </React.Fragment>;
  } );
